<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: register.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."register.php";
include LOCALE.LOCALESET."user_fields.php";
//Henter avloserid fra URL
$avloserid=$_GET['avloserid'];
//---------------------------------------------------------------------------------------------------------------------+
//------Funksjon for bekreftelse og sletting av kontrakt mot DB   (Hoppes over hvis ikke slettknappen er trykket)------+
//---------------------------------------------------------------------------------------------------------------------+
if(isset($_GET['slett']))

if(isset($_GET['confirm']))
{
	$image_id=$_GET['image_id'];
	$confirm=$_GET['confirm'];
	if ($_GET['confirm'] == "ja" )
		{
		$query = "DELETE 
				  FROM images 
				  WHERE avloserid='$avloserid' AND image_id='$image_id'";
		mysql_query($query);
		header("Refresh: 1; url=dokument.php?avloserid=".$_GET['avloserid']."&sjekk=nei");
		}
}
//---------------------------------------------------------------------------------------------------------------------+
//------------------------------------Slutt-på-funksjon-for-sletting-av-kontrakt---------------------------------------+
//---------------------------------------------------------------------------------------------------------------------+

//Henter sjekk fra URL

//Oppkobling mot databasen. Opkoblingsinfo ligger i config.php
//--------------------------------------------------------------------------------------------
$db = mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'], $GLOBALS['db_password']);
mysql_select_db($GLOBALS['db_name'], $db);  

//--------------------------------------------------------------------------------------------
// Her begynner koden for å hente ut data om kurs

$query=" SELECT * 
		 FROM avloser 
		 WHERE avloserid='$avloserid'";
$result=mysql_query($query);
$num1=mysql_numrows($result);

$i=0;
while ($i < $num1) {
$fornavn=mysql_result($result,$i,"fornavn");
$etternavn=mysql_result($result,$i,"etternavn");
++$i;
}

$query="SELECT image_id, avloserid, filnavn 
		FROM images 
		WHERE avloserid='$avloserid'";
$result=mysql_query($query);
$num=mysql_numrows($result);

echo "
	<p >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='profil.php?avloserid=$avloserid'><b><---  Tilbake til profil</b></a></p>
	<table class='capmain' border='0' cellpadding='0' align='center'>
		<tr>
			<th>Dokumenter for $fornavn  $etternavn</th>
		</tr>
	</table>
	<table class='imagetable' border='0' cellpadding='5' align='center'>
		<tr>
			<th><b>Filnavn</b></th> <th></th>
		</tr>
		
";
$i=0;
while ($i < $num) {
	$filnavn=mysql_result($result,$i,"filnavn");
	$avloserid=mysql_result($result,$i,"avloserid");
	$image_id=mysql_result($result,$i,"image_id");
++$i;
echo "
	<form action='dokument.php?confirm=ja&image_id=".$image_id."&avloserid=".$avloserid."&slett=ja&sjekk=nei' onSubmit='return validateUpdate()' method='post'>
		<tr>
			<td><b> <a href='dokumentview.php?image_id=$image_id' target='_BLANK'> $filnavn </a> </b></td>
			<td align=center><input type='submit' value='Slett'/></td>
		</tr></form>
";
} //Slutt på While-løkke
echo "</table>";
$avloserid=$_GET['avloserid']; 

$query="SELECT avloserid 
		FROM avloser 
		WHERE avloserid='$avloserid'";
$result=mysql_query($query);
$num=mysql_numrows($result);

$i=0;
while ($i < $num) {
$avloserid=mysql_result($result,$i,"avloserid");
++$i;
}


echo "

	<br></br>
	<table class='capmain' border='0' cellpadding='0' align='center' width='608px'>
		<tr>
			<th><font style='text-transform: capitalize;'>Last opp dokument </font></th>
		</tr>
	</table>

	<form method='post' action='process.php?avloserid=".$avloserid."&sjekk=ja'' enctype='multipart/form-data'>
	<input type='hidden' name='ud_avloserid' value=$avloserid>
	<input type='hidden' name='avloserid' value='$avloserid' maxlength='30' style='width:200px;' />
	

	<table class='imagetable' cellpadding='0' cellspacing='0' align='center'>
	
		<tr>
			<th>Filnavn:</th>			<td><input type='text' name='filnavn' maxlength='70' style='width:200px;' /></td>
                    
		</tr>
		
		<tr>
			<th>Last opp:</th>		<td><input type='file' name='image' /><input type='submit' value='Last Opp' /></td>
                    
		</tr>
		

</table><br></br>";

//Her slutter koden for å hente ut data om skolegang
require_once THEMES."templates/footer.php";
?>
<!-- JavaScript and HTML codes by Quackit.com -->
<script language="javascript" type="text/javascript" >
function validateUpdate(){
		var confirmLeave = confirm('Er du sikker?');
		return confirmLeave;
}
</script>